<div class="box">
    <div class="box-header">
        <h3 class="box-title"></h3>
        <div class="pull-right"> 
            <div class="form-inline pull-right">
                <form action="{{admin_url('crm_kehutongji')}}/kehu" method="post" >
                    <fieldset>
                        {{ csrf_field() }}
                            <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>客户类别</strong></span>
                    <select class="form-control customer_type" style="width: 100%;" name="customer_type">
                            <option value="" >选择</option>
                            <option value="单位" >单位</option>
                            <option value="个人" >个人</option>
                    </select></div>
                                            <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>客户来源</strong></span>
                    <select class="form-control customer_laiyuan" style="width: 100%;" name="customer_laiyuan">
                            <option value="" >选择</option>
                            <option value="1" >网站</option>
                            <option value="2" >转介绍</option>
                            <option value="3" >上门</option>
                            <option value="4" >电话销售</option>
                            <option value="5" >老客户</option>
                            <option value="6" >其他</option>
                    </select></div>
                                            <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>客户姓名</strong></span>
                    <input type="text" class="form-control" placeholder="客户姓名" name="customer_name" value=""></div>
                                            <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>客户电话</strong></span>
                    <input type="text" class="form-control" placeholder="客户电话" name="customer_phone" value=""></div>
                                            <div class="input-group input-group-sm">
                    <span class="input-group-addon"><strong>单位名称</strong></span>
                    <input type="text" class="form-control" placeholder="单位名称" name="customer_danwei" value=""></div>
                                            <div class="input-group input-group-sm">
                            <span class="input-group-addon"><strong>部门</strong></span>
                            <select class="form-control bumen" style="width: 100%;" name="bumen" id="bumen">
                            <option value>选择</option>
                            @foreach($list['bumen'] as $vo)
                            <option value="{{$vo->id}}">{{$vo->name}}</option>
                            @endforeach
                            </select>
                        </div>
                        <div class="input-group input-group-sm">
                            <span class="input-group-addon"><strong>维护人</strong></span>
                            <select class="form-control yuangong" style="width: 100%;" name="yuangong" id="yuangong">
                            <option value>选择</option>
                            @foreach($list['yuangong'] as $vo)
                            <option value="{{$vo->id}}">{{$vo->username}}</option>
                            @endforeach
                        </select>
                        </div>
                    <div class="input-group input-group-sm">
                            <span class="input-group-addon"><strong>下单日期</strong></span>
                            <input type="text" class="form-control" id="order_lvyoudate_start" placeholder="下单日期" name="order_lvyoudate[start]" value="">
                            <span class="input-group-addon" style="border-left: 0; border-right: 0;">-</span>
                            <input type="text" class="form-control" id="order_lvyoudate_end" placeholder="下单日期" name="order_lvyoudate[end]" value="">
                        </div>
                                        <div class="btn-group btn-group-sm">
                                <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i></button>
                                <a href="{{admin_url('crm_kehutongji')}}" class="btn btn-warning" ><i class="fa fa-undo"></i></a>
                            </div>
                            

                        </fieldset>
                    </form>
            </div>
        </div>
    </div>
    <!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
        <table id="table" class="table table-hover">
            <tbody>
                <tr>
                    <th>客户姓名</th>
                    <th>客户电话</th>
                    <th>客户类别</th>
                    <th>单位</th>
                    <th>客户来源</th>
                    <th>维护人</th>
                    <th>录入时间</th>
                    <th>实际利润</th>
                </tr>
                @foreach($list['list'] as $value)
                <tr>
                    <td>{{$value->customer_name}}</td>
                    <td>{{$value->customer_phone}}</td>
                    <td>{{$value->customer_type}}</td>
                    <td>{{$value->customer_danwei}}</td>
                    @foreach($list['laiyuan'] as $k=>$vo)
                        @if($value->customer_laiyuan==$k)
                        <td>{{$vo}}</td>
                        @endif
                    @endforeach
                    @foreach($list['user'] as $ko)
                        @if($value->customer_weihu==$ko->id)
                        <td>{{$ko->username}}</td>
                        @endif
                    @endforeach
                    <td>{{$value->customer_kfdate}}</td>
                    <td>0</td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>
<script>

    $(function () {
        $('#order_lvyoudate_start').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh_CN"});
        $('#order_lvyoudate_end').datetimepicker({"format":"YYYY-MM-DD HH:mm:ss","locale":"zh_CN","useCurrent":false});
        $("#order_lvyoudate_start").on("dp.change", function (e) {
        $('#order_lvyoudate_end').data("DateTimePicker").minDate(e.date);
        });
        $("#order_lvyoudate_end").on("dp.change", function (e) {
            $('#order_lvyoudate_start').data("DateTimePicker").maxDate(e.date);
        });
        $(".bumen").change(function(){
            var id=$(".bumen option:selected").val();
            $.ajax({
                url: "/admin/gdindex/ajax13",
                type: "get",
                dataType: "json",
                data: {'v': id},
                success:function(data){
                    var hh="<option value>请-选-择<\/option>";
                    for(var i=0;i<data.length;i++){
                        hh +="<option value="
                        hh +=data[i].id
                        hh +=" >"
                        hh +=data[i].username
                        hh +="<\/option>";
                       
                    }
                    $(".yuangong").html(hh);
                }
            }); 
        })
    })
</script>